home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / gfx / misc / gnuplot-src.lha / gnuplot-3.7.1src / gnuplot-3.7.1.lha / gnuplot-3.7.1 / term / vws.trm < prev    next >
Encoding:
Text File  |  1998-12-14  |  15.3 KB  |  499 lines

  1. /*
  2.  * $Id: v VWS",
  3. "?VWS",
  4. "8/12/14 18:41:49 lhecking Exp $
  5.  *
  6.  */
  7.  
  8. /* GNUPLOT - vws.trm */
  9.  
  10. /*[
  11.  * Copyright 1990 - 1993, 1998
  12.  *
  13.  * Permission to use, copy, and distribute this software and its
  14.  * documentation for any purpose with or without fee is hereby granted,
  15.  * provided that the above copyright notice appear in all copies and
  16.  * that both that copyright notice and this permission notice appear
  17.  * in supporting documentation.
  18.  *
  19.  * Permission to modify the software is granted, but not the right to
  20.  * distribute the complete modified source code.  Modifications are to
  21.  * be distributed as patches to the released version.  Permission to
  22.  * distribute binaries produced by compiling modified sources is granted,
  23.  * provided you
  24.  *   1. distribute the corresponding source modifications from the
  25.  *    released version in the form of a patch file along with the binaries,
  26.  *   2. add special version identification to distinguish your version
  27.  *    in addition to the base release version number,
  28.  *   3. provide your name and address as the primary contact for the
  29.  *    support of your modified version, and
  30.  *   4. retain our contact information in regard to use of the base
  31.  *    software.
  32.  * Permission to distribute the released version of the source code along
  33.  * with corresponding source modifications in the form of a patch file is
  34.  * granted with same provisions 2 through 4 for binary distributions.
  35.  *
  36.  * This software is provided "as is" without express or implied warranty
  37.  * to the extent permitted by applicable law.
  38. ]*/
  39.  
  40. /*
  41.  * This file is included by ../term.c.
  42.  *
  43.  * This terminal driver supports:
  44.  *   IRIS terminals
  45.  *
  46.  * AUTHORS
  47.  *   Walter Speth
  48.  *           BITNET: SPETH@DBNPIB5
  49.  *
  50.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  51.  *
  52.  */
  53. /*
  54.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  55.  * adapted to VAX VMS 4.7, VAX C 2.4 and activated the INTENSITY and COLOR 
  56.  * monitor features (Lucas P. Hart, June 1997) 
  57.  */
  58.  
  59. #include "driver.h"
  60.  
  61. #ifdef TERM_REGISTER
  62. register_term(vws)
  63. #endif
  64.  
  65. #ifdef TERM_PROTO
  66. TERM_PUBLIC void VWS_init __PROTO((void));
  67. TERM_PUBLIC void VWS_reset __PROTO((void));
  68. TERM_PUBLIC int VWS_scale __PROTO((double xs, double ys));
  69. TERM_PUBLIC void VWS_graphics __PROTO((void));
  70. TERM_PUBLIC void VWS_text __PROTO((void));
  71. TERM_PUBLIC void VWS_move __PROTO((unsigned int x, unsigned int y));
  72. TERM_PUBLIC void VWS_vector __PROTO((unsigned int x, unsigned int y));
  73. TERM_PUBLIC void VWS_linetype __PROTO((int lt));
  74. TERM_PUBLIC void VWS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
  75. TERM_PUBLIC int VWS_text_angle __PROTO((int ang));
  76. TERM_PUBLIC int VWS_justify_text __PROTO((enum JUSTIFY mode));
  77. TERM_PUBLIC void VWS_point __PROTO((unsigned int x, unsigned int y, int point));
  78. TERM_PUBLIC void VWS_arrow __PROTO((unsigned int sx, unsigned int sy,
  79.                     unsigned int ex, unsigned int ey, int head));
  80.  
  81. #define VWS_XMAX 1024
  82. #define VWS_YMAX 780        /* VAXstation 2000 is 864 */
  83. #define VWS_VCHAR 25
  84. #define VWS_HCHAR 15
  85. #define VWS_VTIC 10
  86. #define VWS_HTIC 10
  87. #endif /* TERM_PROTO */
  88.  
  89. #ifndef TERM_PROTO_ONLY
  90. #ifdef TERM_BODY
  91. void VWS_resize_ast __PROTO((void));
  92.  
  93. #include <ssdef.h>
  94. /* */
  95. #include <descrip.h>
  96.  
  97. #include <uisentry.h>
  98. #include <uisusrdef.h>
  99.  
  100. #define DEFAULT_ATTR 0
  101. #define OVER_ATTR 1
  102. #define ERAS_ATTR 2
  103. #define BIS_ATTR 3
  104. #define COLOR_ATTR 4
  105. #define TEXT_ATTR 5
  106. #define LINE_ATTR 6
  107. #define BACK_ATTR 7
  108.  
  109. float current_x, current_y;
  110.  
  111. int vd_id, wd_id;
  112. int vcm_id, ws_type;
  113.  
  114. static $DESCRIPTOR(ws_devname, "SYS$WORKSTATION");
  115. static $DESCRIPTOR(vd_title, "gnuplot");
  116.  
  117. static float x0, y0, xsiz, ysiz, wc_xmin_new, wc_ymin_new, wc_xmax_new, wc_ymax_new, wc_xmin,
  118. wc_ymin, wc_xmax, wc_ymax, vd_width, vd_height;
  119.  
  120. void VWS_resize_ast()
  121. {
  122.     extern void replotrequest();    /* in command.c */
  123.     uis$resize_window(&vd_id, &wd_id, &x0, &y0, &xsiz, &ysiz,
  124.               &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
  125.     replotrequest();
  126. }
  127.  
  128. /****************************************************************************/
  129. TERM_PUBLIC void VWS_init()
  130. {
  131.     int i;
  132.     int cattr;
  133.     $DESCRIPTOR(a_font, "DTABER0003WK00PG0001UZZZZ02A000");
  134.     const int i0 = 0, i1 = 1, i2 = 2, i3 = 3, i4 = 4, i5 = 5, i6 = 6, i7 = 7, i8 = 8;
  135.     const float p0 = 0.0, p1 = 0.1, p2 = 0.2, p3 = 0.3, p4 = 0.4;
  136.     const float p5 = 0.5, p6 = 0.6, p7 = 0.7, p8 = 0.8, p9 = 0.9;
  137.     const int n1 = 0xFFFFFFFF;
  138.     const int uis$c_mode_over = UIS$C_MODE_OVER;
  139.     const int uis$c_mode_eras = UIS$C_MODE_ERAS;
  140.     const int uis$c_mode_bis = UIS$C_MODE_BIS;
  141.     const float vws_hchar = (float) VWS_HCHAR;
  142.     const float vws_vchar = (float) VWS_VCHAR;
  143.     const int default_attr = DEFAULT_ATTR;
  144.     const int over_attr = OVER_ATTR;
  145.     const int eras_attr = ERAS_ATTR;
  146.     const int bis_attr = BIS_ATTR;
  147.     const int color_attr = COLOR_ATTR;
  148.     const int text_attr = TEXT_ATTR;
  149.     const int line_attr = LINE_ATTR;
  150.     const int back_attr = BACK_ATTR;
  151.  
  152. /* lph:  the similar notation may lead to some confusion
  153.  * attributes are grouped in "attribute block" data structures
  154.  * which are referenced by block number
  155.  * attribute block 0 contains default attribute settings
  156.  *
  157.  * To customize settings, a function will read the source 
  158.  * attribute block, set the particular attribute, and
  159.  * write to the destination attribute block.
  160.  * Both the block number and attribute are integers, so it
  161.  * is easy to confuse an attribute and an attribute blcok
  162.  */
  163.  
  164. /*  lph:  Color map corresponding to an example in
  165.  *  MicroVMS Graphics Progamming Guide (V3.0) */
  166.  
  167.     const float r_map[8] = { 0.40, 0.50, 0.50, 0.00, 0.25, 0.90, 0.80, 0.35 };
  168.     const float g_map[8] = { 0.30, 0.50, 0.25, 0.70, 0.25, 0.50, 0.30, 0.65 };
  169.     const float b_map[8] = { 0.00, 0.50, 0.50, 0.30, 0.90, 0.00, 0.00, 0.95 };
  170.  
  171. /* the array format is easier to customize */
  172.  
  173.     vd_width = 14;
  174.     vd_height = 10;        /* aspect sqrt(2) as DIN A paper */
  175.  
  176.     wc_xmin = 0.0;
  177.     wc_ymin = 0.0;
  178.     wc_xmax = (float) VWS_XMAX;
  179.     wc_ymax = (float) VWS_YMAX;
  180.  
  181.     vcm_id = uis$create_color_map(&i8);
  182.  
  183.     vd_id = uis$create_display(&wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
  184.                    &vd_width, &vd_height, &vcm_id);
  185.     uis$get_hw_color_info(&ws_devname, &ws_type);
  186.  
  187. /* lph: ws's color table for monochrome  */
  188. /* by default,  color table index 0 is backgound, and 1 is foregound */
  189. /* a color {index into the color table} is assigned to the active line */
  190. /* in VWS_linetype */
  191.  
  192.     if (ws_type == UIS$C_DEV_MONO) {
  193.     uis$set_color(&vd_id, &i0, &p5, &p5, &p5);
  194.     uis$set_color(&vd_id, &i1, &p0, &p0, &p0);
  195.     uis$set_color(&vd_id, &i2, &p0, &p0, &p0);
  196.     uis$set_color(&vd_id, &i3, &p0, &p0, &p0);
  197.     uis$set_color(&vd_id, &i4, &p0, &p0, &p0);
  198.     uis$set_color(&vd_id, &i5, &p0, &p0, &p0);
  199.     uis$set_color(&vd_id, &i6, &p0, &p0, &p0);
  200.     uis$set_color(&vd_id, &i7, &p0, &p0, &p0);
  201.     } else if (ws_type == UIS$C_DEV_INTENSITY) {
  202.         /* Intensity scale, untested */
  203.     uis$set_color(&vd_id, &i2, &p2, &p2, &p2);
  204.     uis$set_color(&vd_id, &i3, &p3, &p3, &p3);
  205.     uis$set_color(&vd_id, &i4, &p4, &p4, &p4);
  206.     uis$set_color(&vd_id, &i5, &p5, &p5, &p5);
  207.     uis$set_color(&vd_id, &i6, &p6, &p6, &p6);
  208.     uis$set_color(&vd_id, &i7, &p7, &p7, &p7);
  209.     }
  210.     /* ws: perhaps better for color terms (which I do not have) */
  211.  
  212.     else if (ws_type == UIS$C_DEV_COLOR) {
  213. /* */
  214.     uis$set_color(&vd_id, &i0, &p0, &p0, &p0);
  215.     uis$set_color(&vd_id, &i1, &p9, &p0, &p0);
  216.     uis$set_color(&vd_id, &i2, &p0, &p9, &p0);
  217.     uis$set_color(&vd_id, &i3, &p9, &p9, &p0);
  218.     uis$set_color(&vd_id, &i4, &p0, &p0, &p9);
  219.     uis$set_color(&vd_id, &i5, &p9, &p0, &p9);
  220.     uis$set_color(&vd_id, &i6, &p0, &p9, &p9);
  221.     uis$set_color(&vd_id, &i7, &p9, &p9, &p9);
  222.     /*
  223.        * lph: Another way to set up the color table is to use arrays,
  224.        * which simplifies customizing the appearance.
  225.        *
  226.        uis$set_colors(&vd_id, &i0, &i8, &r_map, &g_map, &b_map);  
  227.      */
  228.     }
  229.     uis$disable_display_list(&vd_id);
  230.  
  231.     wd_id = uis$create_window(&vd_id, &ws_devname, &vd_title,
  232.                   &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
  233.                   &vd_width, &vd_height);
  234.  
  235.     uis$set_resize_ast(&vd_id, &wd_id, &VWS_resize_ast, &i0,
  236.                &x0, &y0, &xsiz, &ysiz,
  237.                &wc_xmin_new, &wc_ymin_new, &wc_xmax_new, &wc_ymax_new);
  238. /* 
  239.  * lph: This sets up three different attribute blocks, each having a different
  240.  * mode, but they are never utilized and it is not clear when they might
  241.  * be of use.
  242.  * The attribute blocks used for writing are line_attr, text_attr.
  243.  * 
  244.   uis$set_writing_mode(&vd_id, &default_attr, &over_attr, &uis$c_mode_over);
  245.   uis$set_writing_mode(&vd_id, &default_attr, &eras_attr, &uis$c_mode_eras);
  246.   uis$set_writing_mode(&vd_id, &default_attr, &bis_attr, &uis$c_mode_bis);
  247.  */
  248.  
  249. /* lph:  this was commented out;  it changes the COLOR_ATTR BLOCK and 
  250.  * the following BLOCKS
  251.  *
  252. if (ws_type >=  UIS$C_DEV_INTENSITY) {
  253.   for (i=0; i<8; i++) {
  254.   cattr = COLOR_ATTR+i;
  255.   uis$set_writing_index(&vd_id, &default_attr, &cattr, &i);
  256.   }
  257.   }
  258.  *
  259.   */
  260.  
  261. /* lph: default value for the background index into the virtual color
  262. /* table is 0, and the back_attr block is never used
  263.  *
  264.   uis$set_background_index(&vd_id, &default_attr, &back_attr, &i0);
  265.  *
  266.  * the rest look OK, setting up the two attribute blocks 
  267.  */
  268.     uis$set_writing_mode(&vd_id, &default_attr, &text_attr, &uis$c_mode_over);
  269.     uis$set_font(&vd_id, &text_attr, &text_attr, &a_font);
  270.     uis$set_char_size(&vd_id, &text_attr, &text_attr, &i0, &vws_hchar, &vws_vchar);
  271.     uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
  272. }
  273.  
  274. /****************************************************************************/
  275.  
  276. TERM_PUBLIC void VWS_reset()
  277. {
  278.     uis$delete_display(&vd_id);
  279. }
  280.  
  281. /****************************************************************************/
  282. TERM_PUBLIC int VWS_scale(xs, ys)
  283. double xs, ys;
  284. {
  285.     return FALSE;
  286. }
  287. /****************************************************************************/
  288. TERM_PUBLIC void VWS_graphics()
  289. {
  290.     uis$erase(&vd_id, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
  291. }
  292.  
  293. /****************************************************************************/
  294. TERM_PUBLIC void VWS_text()
  295. {
  296. }
  297.  
  298. /****************************************************************************/
  299. TERM_PUBLIC void VWS_move(x, y)
  300. unsigned int x, y;
  301. {
  302.     current_x = (float) (x);
  303.     current_y = (float) (y);
  304. }
  305.  
  306. /****************************************************************************/
  307. TERM_PUBLIC void VWS_vector(x, y)
  308. unsigned int x, y;
  309. {
  310.     int col;
  311.     int line_attr = LINE_ATTR;
  312.     float fx, fy;
  313.     fx = (float) x;
  314.     fy = (float) y;
  315.  
  316.     uis$line(&vd_id, &line_attr, ¤t_x, ¤t_y, &fx, &fy);
  317.     VWS_move(x, y);
  318. }
  319.  
  320. /****************************************************************************/
  321. TERM_PUBLIC void VWS_linetype(lt)
  322. int lt;
  323. {
  324.     const int n1 = 0xFFFFFFFF;
  325.     /* indices into the color map */
  326.     const int i[8] = {0, 1, 2, 3, 4, 5, 6, 7};
  327.     const float p15 = 2.0, p20 = 3.0, p10 = 1.0;
  328.     long int lstyle[9] =
  329.     {0xffffffff,
  330.      0Xff00ff00,
  331.      0xffffff00,
  332.      0xffff0000,
  333.      0xf0f0f0f0,
  334.      0Xfff0fff0,
  335.      0xf000f000,
  336.      0xa5a5a5af,
  337.      0xf00f00f0
  338.     };
  339.     int line_attr = LINE_ATTR;
  340.     /* use multiplier of normal line width; default is width in pixels */
  341.     const int uis$c_width_world = UIS$C_WIDTH_WORLD;
  342.  
  343.     if (lt < 0) {
  344.     switch (lt) {
  345.     case -1:        /* used for axis */
  346.         uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
  347.         uis$set_line_width(&vd_id, &line_attr, &line_attr, &p15,
  348.                    &uis$c_width_world);
  349.         if (ws_type >= UIS$C_DEV_INTENSITY) {
  350.         uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
  351.         }
  352.         break;
  353.     case -2:        /* the borders */
  354.         uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
  355.         uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
  356.                    &uis$c_width_world);
  357.         if (ws_type >= UIS$C_DEV_INTENSITY) {
  358.         uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
  359.         }
  360.         break;
  361.     default:        /* else a thick line ? */
  362.         uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
  363.         uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
  364.                    &uis$c_width_world);
  365.         if (ws_type >= UIS$C_DEV_INTENSITY) {
  366.         uis$set_writing_index(&vd_id, &line_attr, &line_attr,
  367.                       &i[1 + ((-lt) % 7)]);
  368.         }
  369.         break;
  370.     }
  371.     } else {
  372. /* assign the color index (excluding the background index, 0*/
  373.     if (ws_type >= UIS$C_DEV_INTENSITY) {
  374.         uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1 + lt % 7]);
  375.     }
  376. /* assign the line style
  377.     uis$set_line_style(&vd_id,&line_attr,&line_attr,&lstyle[lt % 8]);
  378.  * ws: makes part of curve disappear on my workstation
  379.  * lph: also observed w/ VS2000 and 4 plane graphics coprocesssor; line 
  380.  * types change appropriately, but has problems as pixels/line segment 
  381.  * decreases.  Better with full screen display and "set samples" smaller
  382.  * but start out with only solid lines
  383.   */
  384.     uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
  385.  
  386.     uis$set_line_width(&vd_id, &line_attr, &line_attr, &p10,
  387.                &uis$c_width_world);
  388.     }
  389. }
  390.  
  391. /****************************************************************************/
  392. static int justify_mode = CENTRE, up;
  393.  
  394. TERM_PUBLIC void VWS_put_text(x, y, str)
  395. unsigned int x, y;
  396. char *str;
  397. {
  398.     float fx, fy, thih, twid;
  399.     int text_attr = TEXT_ATTR;
  400.  
  401. /* uis$text parameter is descriptor string not character string */
  402.  
  403.     struct dsc$descriptor_s textline =
  404.     {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, ""};
  405.  
  406.  
  407.     textline.dsc$a_pointer = str;
  408.     textline.dsc$w_length = strlen(textline.dsc$a_pointer);
  409.     uis$measure_text(&vd_id, &text_attr, &textline, &twid, &thih);
  410.     fx = (float) x;
  411.     fy = (float) y;
  412.  
  413.     switch (justify_mode) {
  414.     case LEFT:
  415.     fy += thih / 2.;
  416.     break;
  417.     case RIGHT:
  418.     fy += thih / 2.;
  419.     fx -= twid;
  420.     break;
  421.  
  422.     case CENTRE:
  423.     fy += thih / 2.;
  424.     fx -= twid / 2;
  425.     break;
  426.     };
  427.  
  428.     uis$text(&vd_id, &text_attr, &textline, &fx, &fy);
  429.     /* write to Example Viewport window */
  430.  
  431.  
  432. }
  433. /****************************************************************************/
  434. TERM_PUBLIC int VWS_text_angle(ang)
  435. int ang;
  436. {
  437.     float degrees;
  438.     int text_attr = TEXT_ATTR;
  439.     degrees = 90. * (up = ang);
  440.     uis$set_text_slope(&vd_id, &text_attr, &text_attr, °rees);
  441.     return TRUE;
  442. }
  443. /****************************************************************************/
  444. TERM_PUBLIC int VWS_justify_text(mode)
  445. enum JUSTIFY mode;
  446. {
  447.     justify_mode = mode;
  448.     return TRUE;
  449. }
  450. /****************************************************************************/
  451. TERM_PUBLIC void VWS_point(x, y, point)
  452. unsigned int x, y;
  453. int point;
  454. {
  455.     do_point(x, y, point);
  456. }
  457.  
  458. /****************************************************************************/
  459. TERM_PUBLIC void VWS_arrow(sx, sy, ex, ey, head)
  460. unsigned int sx, sy, ex, ey;
  461. int head;
  462. {
  463.     do_arrow(sx, sy, ex, ey, head);
  464. }
  465.  
  466. #endif /* TERM_BODY */
  467.  
  468. #ifdef TERM_TABLE
  469.  
  470. TERM_TABLE_START(vws_driver)
  471.     "VWS", "VAX Windowing System (UIS)",
  472.     VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
  473.     VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
  474.     VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
  475.     VWS_linetype, VWS_put_text, VWS_text_angle,
  476.     VWS_justify_text, do_point, do_arrow, set_font_null
  477. TERM_TABLE_END(vws_driver)
  478.  
  479. #undef LAST_TERM
  480. #define LAST_TERM vws_driver
  481.  
  482. #endif /* TERM_TABLE */
  483. #endif /* TERM_PROTO_ONLY */
  484.  
  485. #ifdef TERM_HELP
  486. START_HELP(VWS)
  487. "1 VWS",
  488. "?commands set terminal VWS",
  489. "?set terminal VWS",
  490. "?set term VWS",
  491. "?terminal VWS",
  492. "?term VWS",
  493. "?VWS",
  494. " The `VWS` terminal driver supports the VAX Windowing System.  It has",
  495. " no options.  It will sense the display type (monochrome, gray scale,",
  496. " or color.)  All line styles are plotted as solid lines."
  497. END_HELP(VWS)
  498. #endif /* TERM_HELP */
  499.